package com.example.learn_spring_boot3.controller;

import com.example.learn_spring_boot3.entity.UserOrder;
import com.example.learn_spring_boot3.mapper.UserOrderMapper;
import com.example.learn_spring_boot3.utils.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("userOrder")
public class UserOrderController {
    @Autowired
    UserOrderMapper userOrderMapper;

    @GetMapping("/getList")
    public ResponseEntity<ResponseData> getList() {
        List<UserOrder> userOrders = userOrderMapper.selectAllOrdersAndUser();
        return ResponseEntity.ok(ResponseData.success(userOrders));
    }
}
